# Contributor: Grigory Kirillov <txgk@bk.ru>
# Maintainer:
pkgname=libntl
pkgver=11.5.1
pkgrel=3
pkgdesc="Library for doing number theory"
url="https://libntl.org"
arch="all"
license="LGPL-2.1-or-later"
makedepends="autoconf automake gf2x-dev gmp-dev perl"
source="https://libntl.org/ntl-$pkgver.tar.gz"
subpackages="$pkgname-static $pkgname-dev $pkgname-doc"
builddir="$srcdir/ntl-$pkgver/src"

prepare() {
	default_prepare

	cd libtool-origin
	update_config_guess
	update_config_sub
}

build() {
	export CXXFLAGS="${CXXFLAGS/-Os/-O2}" # gotta go fast

	# This configure script wasn't generated by autoconf, however during
	# configuration an inlying perl scripts will use autoconf utilities...
	./configure \
		NATIVE=off \
		SHARED=on \
		TUNE=generic \
		CXXFLAGS="$CXXFLAGS" \
		LDFLAGS="$LDFLAGS" \
		DEF_PREFIX=/usr \
		NTL_GF2X_LIB=on \
		NTL_GMP_LIP=on
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

sha512sums="
cf1f642b8a0f9cdc6dda888e07183817dc67ff494e56a852053aeb15b3d2a0e61fbc05824779c5d1f20b8115fba6f97266acf7e0b0b527c25df5989c86d5928f  ntl-11.5.1.tar.gz
"
